package com.example.easeimpro.controller.fragment;

import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.hyphenate.EMCallBack;
import com.hyphenate.EMMessageListener;
import com.hyphenate.chat.EMClient;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.interfaces.MessageListItemClickListener;
import com.hyphenate.easeui.modules.chat.EaseChatFragment;
import com.hyphenate.easeui.modules.chat.EaseChatInputMenu;
import com.hyphenate.easeui.modules.chat.EaseChatMessageListLayout;
import com.hyphenate.easeui.modules.chat.interfaces.EaseChatExtendMenuItemClickListener;
import com.hyphenate.easeui.modules.chat.interfaces.EaseChatPrimaryMenuListener;
import com.hyphenate.easeui.modules.chat.interfaces.IChatEmojiconMenu;
import com.hyphenate.easeui.modules.chat.interfaces.IChatExtendMenu;
import com.hyphenate.easeui.modules.chat.interfaces.IChatPrimaryMenu;
import com.hyphenate.easeui.modules.chat.interfaces.OnChatLayoutListener;
import com.hyphenate.easeui.modules.chat.interfaces.OnRecallMessageResultListener;

import java.util.List;

public class MyEaseChatFragment extends EaseChatFragment {
    private static final String TAG = "MyEaseChatFragment";
    @Override
    public void initView() {
        super.initView();
        EMClient.getInstance().chatManager().addMessageListener(new EMMessageListener() {
            @Override
            public void onMessageReceived(List<EMMessage> messages) {
                Log.e(TAG, "onMessageReceived: " );
            }

            @Override
            public void onMessageRecalled(List<EMMessage> messages) {
                EMMessageListener.super.onMessageRecalled(messages);
                Log.e(TAG, "onMessageReceived: " );
            }
        });


    }

    @Override
    public void initListener() {
        super.initListener();

        EaseChatInputMenu chatlayout = chatLayout.getChatInputMenu();
        //获取到菜单输入控件
        IChatPrimaryMenu primaryMenu = chatlayout.getPrimaryMenu();
//获取到扩展区域控件
        IChatExtendMenu chatExtendMenu = chatlayout.getChatExtendMenu();
//获取到表情区域控件
        IChatEmojiconMenu emojiconMenu = chatlayout.getEmojiconMenu();

       chatExtendMenu.setEaseChatExtendMenuItemClickListener(listener);
        chatLayout.setOnRecallMessageResultListener(new OnRecallMessageResultListener() {
            @Override
            public void recallSuccess(EMMessage message) {
                Log.e(TAG, "recallSuccess: " );

            }

            @Override
            public void recallFail(int code, String errorMsg) {
                Log.e(TAG, "recallFail:"+errorMsg );
            }
        });
     //   chatMessageListLayout.setMessageListItemClickListener(messageListListener);

    }

    EaseChatExtendMenuItemClickListener listener = (itemId, view) -> {
        Log.e(TAG, "listener"+itemId);
    };


}
